package com.shopping.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;

import java.time.LocalDateTime;

@Data
@TableName("cart_items")
public class CartItem {
    @TableId(type = IdType.AUTO)
    private Long id;

    @TableField("user_id")
    private Long userId;

    @TableField("product_id")
    private Long productId;

    @TableField("quantity")
    private Integer quantity = 1;

    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    // 关联的商品信息（非数据库字段）
    @TableField(exist = false)
    private com.shopping.dto.ProductDTO product;

    // 购物车ID（非数据库字段）
    @TableField(exist = false)
    private Long cartId;

    public void setCartId(Long cartId) {
        this.cartId = cartId;
    }
}